def knapsack_01(weights, volumes, values, max_weight, max_volume):
    n = len(weights)
    dp = [[[0, []] for _ in range(max_volume + 1)] for _ in range(max_weight + 1)]

    for i in range(1, n + 1):
        for j in range(max_weight, 0, -1):
            for k in range(max_volume, 0, -1):
                if j >= weights[i - 1] and k >= volumes[i - 1]:
                    if dp[j][k][0] < dp[j - weights[i - 1]][k - volumes[i - 1]][0] + values[i - 1]:
                        dp[j][k][0] = dp[j - weights[i - 1]][k - volumes[i - 1]][0] + values[i - 1]
                        dp[j][k][1] = dp[j - weights[i - 1]][k - volumes[i - 1]][1] + [i - 1]
                else:
                    dp[j][k] = dp[j][k]

    return dp[max_weight][max_volume][0], dp[max_weight][max_volume][1]


weights = [2, 3, 3, 4, 4, 4, 1, 2, 1, 5]
volumes = [4, 3, 2, 5, 2, 3, 2, 2, 4, 5]
values = [4, 2, 4, 2, 5, 1, 5, 4, 2, 5, 1]
max_weight = 10
max_volume = 10

max_value, selected_items = knapsack_01(weights, volumes, values, max_weight, max_volume)

print("最大价值为:", max_value)
print("被选中的物品编号为:", selected_items)
